package poc.gridfs;

import java.io.File;
import java.io.IOException;

import poc.MongoDb;

import com.mongodb.DB;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSInputFile;

public class GridFSDao {
	DB mydb;
	public GridFSDao(String dbUrl){
		mydb = MongoDb.getInstance(dbUrl).getDb();	
	}
	public void save(String fileUri) throws IOException{
		File f =  new File(fileUri);  
        GridFS myFS = new GridFS(mydb);               
        GridFSInputFile inputFile = myFS.createFile(f);  
        inputFile.save();  
	}
}
